package com.choosefine.it.spgeunit.controller;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.choosefine.it.base.BaseController;
import com.choosefine.it.common.def.ResultCode;
import com.choosefine.it.common.utils.StringUtils;
import com.choosefine.it.spgeunit.service.SpgeunitService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value="")
@Api(value="分包单位",description="陈健")
public class SpgeunitController extends BaseController {

	@Autowired
	SpgeunitService spgeunitService;
	/**
	 * @Description：分包单位未付款汇总（陈健）
	 * @Author：chenjian
	 * @Create Date：2017年3月7日
	 * @param：
	 * @return：
	 */
	@RequestMapping(value="/spgeunitUnPayTeam",method=RequestMethod.GET)
	@ApiOperation(value="分包单位应付款汇总（陈健）")
	@ApiImplicitParams({
		@ApiImplicitParam(name="spgeunitId",value="分包单位id",required=true,dataType="integer",paramType="query"),
		@ApiImplicitParam(name="teamUserCode",value="分包承包人租户编号",required=true,dataType="String",paramType="query")
	})
	public String spgeunitUnPayTeam(Integer spgeunitId,String teamUserCode){
		if(spgeunitId.intValue() > 0 &&  StringUtils.isNotBlank(teamUserCode)){
			Map<String, Object> map = new HashMap<>();
			map.put("spgeunitId", spgeunitId);
			map.put("teamUserCode", teamUserCode);
			BigDecimal total = spgeunitService.spgeunitUnPayTeam(map);
			return responseSuccess(total);
		}else{
			return responseFail(ResultCode.MSG_PARAMS_NULL);
		}
	}
	
	/**
	 * @Description：班组的项目个数（陈健）
	 * @Author：chenjian
	 * @Create Date：2017年3月7日
	 * @param：
	 * @return：
	 */
	@RequestMapping(value="/teamHaveProjectCount",method=RequestMethod.GET)
	@ApiOperation(value="班组的项目个数（陈健）")
	@ApiImplicitParams({
		@ApiImplicitParam(name="spgeunitId",value="分包单位id",required=true,dataType="integer",paramType="query"),
		@ApiImplicitParam(name="teamUserCode",value="分包承包人租户编号",required=true,dataType="String",paramType="query")
	})
	public String teamHaveProjectCount(Integer spgeunitId,String teamUserCode){
		if(spgeunitId.intValue() > 0 &&  StringUtils.isNotBlank(teamUserCode)){
			Map<String, Object> map = new HashMap<>();
			map.put("spgeunitId", spgeunitId);
			map.put("teamUserCode", teamUserCode);
			Integer num = spgeunitService.teamHaveProjectCount(map);
			return responseSuccess(num);
		}else{
			return responseFail(ResultCode.MSG_PARAMS_NULL);
		}
	}
}
